package com.codeckz.library_face.ui

import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.fragment.app.Fragment

/**
 *@packageName com.codeckz.library_face.ui
 *@author kzcai
 *@date 2022/1/7
 */
abstract class BaseActivity<V:ViewDataBinding>:AppCompatActivity() {

    open lateinit var binding:V
    open lateinit var context: Context
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        context = this
        binding = DataBindingUtil.setContentView(this, initContentView(savedInstanceState))
        binding.lifecycleOwner = this
    }

    abstract fun initContentView(savedInstanceState: Bundle?): Int

}


abstract class BaseFaceFragment<V:ViewDataBinding>:Fragment(){
    open lateinit var binding:V

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        binding = DataBindingUtil.inflate(inflater,initContentView(savedInstanceState),container,false)

        return binding.root
    }

    abstract fun initContentView(savedInstanceState: Bundle?): Int

}